package com.jiepos.mpos.common.dao;

import org.springframework.stereotype.Repository;

import com.jiepos.mpos.common.constant.DBConstant;
import com.jiepos.mpos.common.constant.SystemConstant;
import com.jiepos.mpos.common.entity.App_Ins_Param_LimitEntity;
import com.jiepos.mpos.core.dao.BaseDao;
import com.jiepos.mpos.core.util.StringUtils;

/**
 * 机构参数限额Dao
 * @author Zhao.Jinkui
 * @version 1.0
 * @ProjectName: mpos
 * @Package com.jiepos.mpos.common.dao
 * @ClassName InsParamLimitDao
 * @history
 * @UpdateRemark []
 * @since 2017/9/27
 */
@Repository
public class InsParamLimitDao extends BaseDao<App_Ins_Param_LimitEntity> {
    /**
     * 删除记录(更新数据状态为删除)
     * @param ins_uuid
     * @param service_param_uuids
     * @param updateuser
     */
    public void deleteRecord(String ins_uuid,String service_param_uuids,String updateuser){
        StringBuffer sqlBuf = new StringBuffer();
        sqlBuf.append(" UPDATE  "+ DBConstant.Table.T_APP_INS_PARAM_LIMIT)
                .append("    SET REC_ST = '"+ SystemConstant.DEL_STATUS+"', ")
                .append("        REC_UPD_TS = SYSTIMESTAMP, ")
                .append("        LAST_OPER_IN = '"+SystemConstant.OPER_DEL+"', ")
                .append("        REC_UPD_USR_ID = '"+updateuser+"' ")
                .append("  WHERE INS_UUID = '"+ins_uuid+"' ");
        if(!StringUtils.isBlank(service_param_uuids)){
            sqlBuf.append("    AND SERVICE_PARAM_UUID NOT IN ('");
            sqlBuf.append(service_param_uuids.replaceAll(",","','"));
            sqlBuf.append("') ");
        }
        jdbcTemplate.update(sqlBuf.toString());
    }
}
